package com.cbh.controller;

import com.cbh.model.User;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class IndexController {

    @RequestMapping("user/gethh")
    @ResponseBody
    public User user(String param) {
        User u = new User();
        u.setUsername(param);
        //u.setUsrename("<script>alert('注入成功!');</script>");
        return u;
    }

    @RequestMapping("index")
    public String index() {
        System.out.println("from index");
        return "index";
    }

    //@Scheduled(cron = "* * * * * * *")
//    @Scheduled(cron = "0/1 * * * * ?")
//    @Scheduled(cron = "0 * 16 * * ?")
    @Scheduled(cron = "0/5 * * * * ?")   //每5秒执行一次
    public void timedTask1() {
        System.out.println("Timed task1:" + System.currentTimeMillis());
    }

    @Scheduled(cron = "0/10 * * * * ?")   //每10秒执行一次
    public void timedTask2() {
        System.out.println("Timed task2:" + System.currentTimeMillis());
    }

}
